cmake_minimum_required(VERSION 3.26)
project(ChatProject)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_PREFIX_PATH "D:/Qt/5.15.2/mingw81_64")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/output/debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/output/debug)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/output/release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/output/release)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(QT_VERSION 5)

set(REQUIRED_LIBS Core Gui Widgets Network Svg)
set(REQUIRED_LIBS_QUALIFIED Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network Qt5::Svg)
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)

include_directories(
        ${PROJECT_SOURCE_DIR}/src/pages
        ${PROJECT_SOURCE_DIR}/src/net
        ${PROJECT_SOURCE_DIR}/src_p/pages_p
)

file(GLOB HEADERS
        ${PROJECT_SOURCE_DIR}/src/pages/*.h
        ${PROJECT_SOURCE_DIR}/src/net/*.h
        ${PROJECT_SOURCE_DIR}/src_p/pages_p/*.h
)

file(GLOB SOURCES
        ${PROJECT_SOURCE_DIR}/src/pages/*.cpp
        ${PROJECT_SOURCE_DIR}/src/net/*.cpp
)

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

add_executable(${PROJECT_NAME} WIN32 main.cpp resource.qrc ${HEADERS} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED})
